#include <Keypad.h>
#include <LiquidCrystal.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
  {
    '1','2','3','R'  }
  ,
  {
    '4','5','6','U'  }
  ,
  {
    '7','8','9','D'  }
  ,
  {
    'K','0','N','M'  }
};
byte rowPins[ROWS] = {
  38, 40, 42, 44}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {
  28, 26, 24, 22}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
 int i=0;
// character LCD example code
// www.hacktronics.com


// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
LiquidCrystal lcd(12, 7, 6, 5, 4, 3, 2);

void setup()
{

  lcd.begin(20,4); // columns, rows. use 16,2 for a 16x2 LCD, etc.

}
void loop(){
  char key = keypad.getKey();

  if (key != NO_KEY){
   
    lcd.setCursor(i,0); // set cursor to column 0, row 0 (the first row)
    lcd.print(key); // change this text to whatever you like. keep it clean.
    i++;
  }
  delay (150);
}
